var skinInfo={}
var imgSrc=''
var webSkin=''
if(localStorage.webSkin){
	webSkin=JSON.parse(localStorage.webSkin);
//	console.log(webSkin)
	imgSrc=webSkin.bgImgSrc
	$(".selectSkin option").eq(webSkin.selectVal).attr('selected',true)
}else{
	imgSrc='static/img/index_bg.jpg'
	$(".selectSkin option").eq(0).attr('selected',true)
}
if(webSkin.selectVal==2){
	$('body').prepend('<canvas id="starsCanvas" style="position: absolute; left: 0; top: 0;"></canvas>')
	$("<scri"+"pt>"+"</scr"+"ipt>").attr({src:'static/js/star-canvas.js',type:'text/javascript',id:'load'}).appendTo($('head').remove('#loadscript')); 	
}else{
	$("#starsCanvas").remove()
	$("script[src='static/js/star-canvas.js']").remove();
}
$(".bgImg").attr('src',imgSrc)

$(".selectSkin").change(function(){
	if($(this).val()==1){
		skinInfo={
			bgImgSrc:'static/img/bgImg/1.jpg',
			selectVal:1,
			skinCss:'static/css/skinCss/skin1.css',
//			skinMap:['#5b3c39','#6f4c48','#6f4c48']
			skinMap:['#0f2d87','#3770ea','#2a56bd']
		}
		$("script[src='static/js/star-canvas.js']").remove();
//		console.log(drawCanvas)
		$('#starsCanvas').remove()
//		drawCanvas = null
		localStorage.setItem("webSkin",JSON.stringify(skinInfo))
		$(".bgImg").attr('src',skinInfo.bgImgSrc)
	}else if($(this).val()==0){
		skinInfo={
			bgImgSrc:'static/img/index_bg.jpg',
			selectVal:0,
			skinCss:'static/css/skinCss/skin0.css',
			skinMap:['#0f2d87','#3770ea','#2a56bd'],
		}  
		$("script[src='static/js/star-canvas.js']").remove();
		$('#starsCanvas').remove()
		localStorage.setItem("webSkin",JSON.stringify(skinInfo))
		$(".bgImg").attr('src',skinInfo.bgImgSrc)
	}else if($(this).val()==2){
		skinInfo={
			bgImgSrc:'static/img/index_bg.jpg',
			selectVal:2,
			skinCss:'static/css/skinCss/skin0.css',
			skinMap:['#0f2d87','#3770ea','#2a56bd'],
			bgCanvace :'static/js/star-canvas.js'
		}  
		localStorage.setItem("webSkin",JSON.stringify(skinInfo))
		$(".bgImg").attr('src',skinInfo.bgImgSrc)
		$('body').prepend('<canvas id="starsCanvas" style="position: absolute; left: 0; top: 0;"></canvas>')
		$("<scri"+"pt>"+"</scr"+"ipt>").attr({src:skinInfo.bgCanvace,type:'text/javascript',id:'load'}).appendTo($('head').remove('#loadscript')); 

	}else if($(this).val()==3){
		skinInfo={
			bgImgSrc:'static/img/bgImg/3.jpg',
			selectVal:3,
			skinCss:'static/css/skinCss/skin3.css',
			skinMap:['#0f2d87','#3770ea','#2a56bd'],
		}  
		$("script[src='static/js/star-canvas.js']").remove();
		$('#starsCanvas').remove()
		localStorage.setItem("webSkin",JSON.stringify(skinInfo))
		$(".bgImg").attr('src',skinInfo.bgImgSrc)
	}
})

